package main

import (
	"fmt"
	"sync"
)

var num int64
var wgg sync.WaitGroup
var lock sync.RWMutex

func main() {
	wgg.Add(10000000)
	for i := 0; i < 10000000; i++ {
		go func() {
			defer wgg.Done()
			lock.Lock()
			num += 1
			lock.Unlock()
		}()
	}
	wgg.Wait()
	fmt.Println(num)
}
